package com.yh.base.common;

import javax.servlet.ServletContext;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * 
 * 从容器中获取Bean
 * 
 * @author  严华
 * @version  [版本号, 2012-11-4]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class AppManager implements ApplicationContextAware {

	private static ServletContext servletContext = null;

	private static ApplicationContext appContext;

	public void setApplicationContext(ApplicationContext ac)
			throws BeansException {
		appContext = ac;
	}

	public static Object getBean(String beanId) {
		System.out.print(beanId);
		return appContext.getBean(beanId);
	}

	public static String getAppAbsolutePath() {
		return servletContext.getRealPath("/");
	}
}
